separatortoolitem: Port to draw vfunc
authorBenjamin Otte <otte@redhat.com>
Mon, 6 Sep 2010 14:20:30 +0000 (16:20 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 26 Sep 2010 13:11:37 +0000 (15:11 +0200)
gtk/gtkseparatortoolitem.c
gtk/gtktoolbar.c
gtk/gtktoolbar.h

index 139cd25c1bfe1d8e3371e6412de3699ca9009233..d8ebb6354ad8970eaf6d72e92be975e1a3f20ef7 100644 (file)
@@ -70,8 +70,8 @@ static void     gtk_separator_tool_item_size_request      (GtkWidget
                                                            GtkRequisition            *requisition);
 static void     gtk_separator_tool_item_size_allocate     (GtkWidget                 *widget,
                                                            GtkAllocation             *allocation);
-static gboolean gtk_separator_tool_item_expose            (GtkWidget                 *widget,
-                                                           GdkEventExpose            *event);
+static gboolean gtk_separator_tool_item_draw              (GtkWidget                 *widget,
+                                                           cairo_t                   *cr);
 static void     gtk_separator_tool_item_add               (GtkContainer              *container,
                                                            GtkWidget                 *child);
 static gint     get_space_size                            (GtkToolItem               *tool_item);
@@ -120,7 +120,7 @@ gtk_separator_tool_item_class_init (GtkSeparatorToolItemClass *class)
   object_class->get_property = gtk_separator_tool_item_get_property;
   widget_class->size_request = gtk_separator_tool_item_size_request;
   widget_class->size_allocate = gtk_separator_tool_item_size_allocate;
-  widget_class->expose_event = gtk_separator_tool_item_expose;
+  widget_class->draw = gtk_separator_tool_item_draw;
   widget_class->realize = gtk_separator_tool_item_realize;
   widget_class->unrealize = gtk_separator_tool_item_unrealize;
   widget_class->map = gtk_separator_tool_item_map;
@@ -340,8 +340,8 @@ gtk_separator_tool_item_button_event (GtkWidget      *widget,
 }
 
 static gboolean
-gtk_separator_tool_item_expose (GtkWidget      *widget,
-                                GdkEventExpose *event)
+gtk_separator_tool_item_draw (GtkWidget *widget,
+                              cairo_t   *cr)
 {
   GtkAllocation allocation;
   GtkToolbar *toolbar = NULL;
@@ -356,8 +356,7 @@ gtk_separator_tool_item_expose (GtkWidget      *widget,
         toolbar = GTK_TOOLBAR (parent);
 
       gtk_widget_get_allocation (widget, &allocation);
-      _gtk_toolbar_paint_space_line (widget, toolbar,
-                                     &(event->area), &allocation);
+      _gtk_toolbar_paint_space_line (widget, toolbar, cr);
     }
 
   return FALSE;
index 5995bf08663d5a1a5f469d16993efef99dd3ee5f..8f5264cb82452e0ca27e19db766cf5940a558fbf 100644 (file)
@@ -3618,14 +3618,14 @@ _gtk_toolbar_get_default_space_size (void)
 void
 _gtk_toolbar_paint_space_line (GtkWidget           *widget,
                               GtkToolbar          *toolbar,
-                              const GdkRectangle  *area,
-                              const GtkAllocation *allocation)
+                               cairo_t             *cr)
 {
   GtkToolbarPrivate *priv = toolbar->priv;
   GtkOrientation orientation;
   GtkStateType  state;
   GtkStyle     *style;
   GdkWindow    *window;
+  int width, height;
   const double start_fraction = (SPACE_LINE_START / SPACE_LINE_DIVISION);
   const double end_fraction = (SPACE_LINE_END / SPACE_LINE_DIVISION);
 
@@ -3636,6 +3636,8 @@ _gtk_toolbar_paint_space_line (GtkWidget           *widget,
   style = gtk_widget_get_style (widget);
   window = gtk_widget_get_window (widget);
   state = gtk_widget_get_state (widget);
+  width = gtk_widget_get_allocated_width (widget);
+  height = gtk_widget_get_allocated_height (widget);
 
   if (orientation == GTK_ORIENTATION_HORIZONTAL)
     {
@@ -3648,20 +3650,20 @@ _gtk_toolbar_paint_space_line (GtkWidget           *widget,
                             NULL);
 
       if (wide_separators)
-        gtk_paint_box (style, window,
+        gtk_cairo_paint_box (style, cr,
                        state, GTK_SHADOW_ETCHED_OUT,
-                       area, widget, "vseparator",
-                       allocation->x + (allocation->width - separator_width) / 2,
-                       allocation->y + allocation->height * start_fraction,
+                       widget, "vseparator",
+                       (width - separator_width) / 2,
+                       height * start_fraction,
                        separator_width,
-                       allocation->height * (end_fraction - start_fraction));
+                       height * (end_fraction - start_fraction));
       else
-        gtk_paint_vline (style, window,
-                         state, area, widget,
+        gtk_cairo_paint_vline (style, cr,
+                         state, widget,
                          "toolbar",
-                         allocation->y + allocation->height * start_fraction,
-                         allocation->y + allocation->height * end_fraction,
-                         allocation->x + (allocation->width - style->xthickness) / 2);
+                         height * start_fraction,
+                         height * end_fraction,
+                         (width - style->xthickness) / 2);
     }
   else
     {
@@ -3674,20 +3676,20 @@ _gtk_toolbar_paint_space_line (GtkWidget           *widget,
                             NULL);
 
       if (wide_separators)
-        gtk_paint_box (style, window,
+        gtk_cairo_paint_box (style, cr,
                        state, GTK_SHADOW_ETCHED_OUT,
-                       area, widget, "hseparator",
-                       allocation->x + allocation->width * start_fraction,
-                       allocation->y + (allocation->height - separator_height) / 2,
-                       allocation->width * (end_fraction - start_fraction),
+                       widget, "hseparator",
+                       width * start_fraction,
+                       (height - separator_height) / 2,
+                       width * (end_fraction - start_fraction),
                        separator_height);
       else
-        gtk_paint_hline (style, window,
-                         state, area, widget,
+        gtk_cairo_paint_hline (style, cr,
+                         state, widget,
                          "toolbar",
-                         allocation->x + allocation->width * start_fraction,
-                         allocation->x + allocation->width * end_fraction,
-                         allocation->y + (allocation->height - style->ythickness) / 2);
+                         width * start_fraction,
+                         width * end_fraction,
+                         (height - style->ythickness) / 2);
     }
 }
 
index 922fa0e790c2e4ee8f02acbf8c0bb8d22ae79432..99a278cfe8e47431f7d913e648eede19b6223379 100644 (file)
@@ -127,8 +127,7 @@ void            gtk_toolbar_set_drop_highlight_item (GtkToolbar      *toolbar,
 gchar *         _gtk_toolbar_elide_underscores      (const gchar         *original);
 void            _gtk_toolbar_paint_space_line       (GtkWidget           *widget,
                                                     GtkToolbar          *toolbar,
-                                                    const GdkRectangle  *area,
-                                                    const GtkAllocation *allocation);
+                                                     cairo_t             *cr);
 gint            _gtk_toolbar_get_default_space_size (void);